package com.ddwl.message.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.message.service.AdvisoryService;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.message.AdvisoryBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.message.AdvisoryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Fu Zhaohui
 * @date 2017/1/3
 */
@Api(tags="在线咨询服务")
@RequestMapping("/advisory")
@RestController
public class AdvisoryController extends BaseController {
    @Autowired
    private AdvisoryService advisoryService;

    @ApiOperation("获取咨询列表")
    @PostMapping
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo<PageVo<AdvisoryVo>> page(@RequestBody PageBo<AdvisoryBo> pageBo) {
        return RestVo.ok(advisoryService.page(pageBo));
    }


    @ApiOperation("保存咨询")
    @RequestMapping(value = "/save")
    public RestVo save(@ApiParam(value = "咨询信息", required = true) @Validated @RequestBody AdvisoryBo bo) {
        advisoryService.save(bo);
        return RestVo.ok();
    }
}
